package com.qiao.glod.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Qiao on 2016/4/8.
 * function：
 */
public abstract class QuickAdapter<T> extends BaseAdapter {
    protected List<T> mData;

    public QuickAdapter(){
        this.mData = new ArrayList<T>();
    }

    public QuickAdapter(List<T> list){
        this.mData = list;
    }

    public void setData(List<T> list){
        mData.clear();
        this.mData.addAll(list);
        notifyDataSetChanged();
    }

    public void addData(List<T> list){
        this.mData.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    public T getData(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public abstract View getView(int position, View convertView, ViewGroup parent);
}